//
//  TTSDisplayView.m
//  record_plugin
//
//  Created by zqj on 2024/9/10.
//tts 播放进度显示

#import "TTSDisplayView.h"



@implementation TTSDisplayView

+ (TTSDisplayView *)instance{
    TTSDisplayView *view = [[NSBundle bundleForClass:[self class]] loadNibNamed:@"TTSDisplayView" owner:self options:nil].firstObject;
    return view;
}

- (void)updateNum:(NSString *)num content:(NSString *)content{
    self.numLab.text = num;
    self.contenTextView.text = content;
    
}



- (void)updateProgress:(float)progress{
    NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:self.contenTextView.text];
    NSInteger toalLen = attributedText.length;
   
    NSInteger length = toalLen * progress;
    if (length >= toalLen) {
        length = toalLen;
    }
    [attributedText addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, toalLen)];
    [attributedText addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, toalLen)];
    [attributedText addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:0 blue:0.4 alpha:1.0] range:NSMakeRange(0, length)];
    self.contenTextView.attributedText = attributedText;
}

@end
